package me.zhengjie.modules.system.service.dto

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeName
import me.zhengjie.common.base.BaseDTO
import me.zhengjie.common.utils.JacksonUtil
import org.apache.commons.lang3.builder.ToStringBuilder
import java.sql.Timestamp
/**
 * @author Kuki Wu
 * @date 2019-03-29
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
@JsonTypeName("JobDTO")
data class JobDTO(
    var id: Long? = null,
    var jpbSort: Long? = null,
    var name: String? = null,
    var enabled: Boolean? = false
):BaseDTO(){
    annotation class Update

    companion object {
        fun fromJson(json: String): JobDTO? {
            val obj=JacksonUtil.parseObject(json, JobDTO::class.java)!!
            return when(obj){
                is JobDTO -> obj
                else -> null
            }
        }
    }

    fun copy(source: JobDTO?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}